package com.zrrd.learn.chapter02;

/**
 * 学习for循环
 *
 * @author asus
 * @version 1.0
 * @date 2023/4/15 13:18
 */
public class LearnFor01 {

    public static void main(String[] args) {
        //定义初始值
        //int aInt = 1;
        //递进 +1
        //++

        //最大值

        //断点（调试bug）
        for (int aInt = 1, aMax = 6; aInt < aMax; aInt++) {

            //System.out.print(aInt + "\t");
            System.out.print((aInt < (aMax >> 1) ? aInt : aMax - aInt) + "\t");
        }

        //计数器    计算1-11的和
        System.out.println(" ------>");
        int sum = 0;
        for (int i = 1, amax = 11; i < amax; i++) {
            sum += i;
        }
        System.out.println(sum);

        System.out.println(" ------>双指针移动（循环次数少 用时少）");
        int sum1 = 0;
        //此处amax的值必须为双数
        for (int i = 1, amax = 10; i < amax; i++, amax--) {
            sum1 += (i + amax);
        }
        System.out.println(sum);

        //敲7
        for (int i = 1, len = 100; i < 100; i++) {
            System.out.println((i % 7 == 0 || i / 10 == 7 || i % 10 == 7) ? i + "鼓掌\t" : "");
        }
        for (int i = 0; i < 100; i++) {
            if (i %2 != 0) {
                System.out.println(i);
            }
        }
    }
}
